package com.nodecollege.cloud.client.config;

import com.nodecollege.cloud.client.interceptor.GlobalLoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class LoginInterceptorConfig extends WebMvcConfigurerAdapter {

    @Bean
    public GlobalLoginInterceptor loginInterceptor() {
        return new GlobalLoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //配置拦截路径
        registry.addInterceptor(loginInterceptor()).addPathPatterns("/**");
        super.addInterceptors(registry);
    }
}